<template>
	<view class="tabs">
		<view class="card  animated fadeIn" hover-class="tada" >
			<view class="" >
				<view class="" style="font-size: 26rpx;color:#999999 ;">
					<text>{{MessageToInfo.toUserName}}</text>
					<text style="margin-left: 20rpx;">{{MessageToInfo.createTime}}</text>
				</view>
			</view>
			<view class="title_1">
				<text class="">{{MessageToInfo.title}}</text>
			</view>
			<view class="content">
				<view>
					{{MessageToInfo.content}}</view>
			</view>
		</view>
		<view class="" style="margin-top: 20rpx;">
			<view style="height: 100rpx;background-color: #FFFFFF;" class="page-section-spacing">
				<view class="scroll-view-item_H" v-for="(item,index) in tabList" @tap="changeTab(index)">
					<view class="animate__animated" hover-class="animate__rubberBand"
						:class="index == isActive ? 'active' :''">
						{{item.name}}
					</view>
					<view class="" :class="index == isActive ? 'line' :''"></view>
				</view>
			</view>
			<view class="page-section-spacing" v-if="this.isActive===0">
				<scroll-view :refresher-triggered=refresherTriggered :refresherThreshold=refresherThreshold
					@refresherrefresh='refresherrefresh()' refresher-background="#FFFFFF" lower-threshold="500" class=""
					>
					<view class="" style="margin-top: 1rpx;">
						<view class="card1 animated fadeIn" hover-class="tada" v-for="(item,index) in MessageToInfo.read.Info">
							<view class="">
								<image style="width: 80rpx;height: 80rpx;border-radius:50%" :src="item.image" />
							</view>
							<view class="" style="width: 570rpx;">
								<text style="font-size: 28rpx;color: #333333;">{{item.name}}</text>
							</view>
						
						</view>
						
					</view>
				</scroll-view>
			</view>
			<view class="page-section-spacing" v-if="this.isActive===1">
				<scroll-view :refresher-triggered=refresherTriggered :refresherThreshold=refresherThreshold
					@refresherrefresh='refresherrefresh()' refresher-background="#FFFFFF" lower-threshold="500" class=""
					>
					<view class="" style="margin-top: 2rpx;">
						<view class="card1 animated fadeIn" hover-class="tada" v-for="(item,index) in MessageToInfo.unread.Info">
							<view class="">
								<image style="width: 80rpx;height: 80rpx;border-radius:50%" :src="item.image" />
							</view>
							<view class="" style="width: 570rpx;">
								<text style="font-size: 28rpx;color: #333333;">{{item.name}}</text>
								<image style="width: 60rpx;height: 60rpx;" src="../../static/images/taecher/dh2@2x.png" @tap="callPhone(item.phone)"/>
								
							</view>
						</view>
					
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script>
	import uQRCode from '@/js_sdk/Sansnn-uQRCode/uqrcode.js'
	export default {
		data() {
			return {
				orderHeight: 500,
				isActive: 0,
				tabList: [{
					id: "1",
					name: '36人已读'
				}, {
					id: "2",
					name: '12人未读'
				}],
				isNull: false,
				hasNextPage: true,
				refresherThreshold: 50,
				refresherTriggered: false,
				_refresherTriggered: false,
				pageNum: 1,
				pageSize: 20,
				MessageToInfo:''

			}
		},
		onReady() {
			let that = this;
			uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
				success(res) { //成功回调函数
					that.orderHeight = res.windowHeight - uni.upx2px(90) //windoHeight为窗口高度，主要使用的是这个

				}
			})
		},
		onLoad(option){
			this.getMessageFromInfo(option.id)
		},
		methods: {
			callPhone(phone){
				// console.log(phone)
				uni.makePhoneCall({
					phoneNumber: phone //仅为示例
				});
			},
			//老师教务通知详情
			getMessageFromInfo(id){
				this.$api.getMessageFromInfo({
					id:id
				}).then((res) => {
					if (res.data.code == 200) {
						console.log(res.data.dataMap)
						this.MessageToInfo = res.data.dataMap
						this.tabList[0].name = res.data.dataMap.read.number+'人已读'
						this.tabList[1].name = res.data.dataMap.unread.number+'人未读'
					}
				})
			},
			async make(pupOrderNo) {
				// 回调方式
				uQRCode.make({
					canvasId: 'qrcode',
					componentInstance: this,
					text: pupOrderNo,
					size: 250,
					margin: 0,
					backgroundColor: '#ffffff',
					foregroundColor: '#000000',
					fileType: 'jpg',
					correctLevel: uQRCode.errorCorrectLevel.H,
					success: res => {
						console.log(res)
					}
				})
			},
			refresherrefresh() {
				console.log("自定义下拉刷新被触发");
				let _this = this;
				if (_this._refresherTriggered) {
					return;
				}
				_this._refresherTriggered = true;
				//界面下拉触发，triggered可能不是true，要设为true
				if (!_this.refresherTriggered) {
					_this.refresherTriggered = true;
				}
				this.getClassOrdersList(_this.payState)
				setTimeout(() => {
					_this.refresherTriggered = false; //触发onRestore，并关闭刷新图标
					_this._refresherTriggered = false;
				}, 1500)

			},

			//点击事件改变swiper
			changeTab(active) {
				this.isActive = active
				if (active == 0) {
					this.payState = ''
					console.log(this.isActive)
				} else if (active == 1) {
					this.payState = 1
				} else if (active == 2) {
					this.payState = 0
				}
				// this.getOrderList(this.payState)

			},
		}
	}
</script>

<style scoped>
	.title_1{
		width: 690rpx;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		font-size: 32rpx;
		color: #333333;
		font-weight: 500;
	}
	page{
		background-color: #F8F8F8;
	}
	.content {
		display: flex;
	}
	.content>view{
		color: #666666;
		font-size: 30rpx;
		line-height: 36rpx;
		
	}
	.card1>view {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.head {
		font-size: 30rpx;
		color: #666666;
		height: 60rpx;
		position: relative;
		border: 1rpx solid white;
	}

	.canvas {
		height: 230px;
		width: 230px;
		margin: 5rpx 0;
	}

	.btn-shop-list {
		background-color: #FF5551;
		border-radius: 50rpx;
		width: 200rpx;
		color: #FFFFFF;
		line-height: 75rpx;
		margin-top: 40rpx;
	}

	.djc-s-a {
		display: flex;
		justify-content: space-between;
		align-items: center;

	}

	.list-1 {
		padding: 0 0 0 20rpx;
	}

	.list-1 view:nth-child(1) {
		font-weight: 600;
		margin-top: -7rpx;
	}

	.list-1 view:nth-child(2) {
		font-size: 24rpx;
		margin-top: 53rpx;
		color: #9e9e9e;
	}

	.info {
		width: 680rpx;
		margin: 0 auto;
		padding-top: 15rpx;

	}

	.aj {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.card {
		/* width: 100%; */
		background-color: #ffffff;
		border-radius: 10rpx;
		padding: 25rpx 30rpx;
	}

	.card1 {
		display: flex;
		height: 100rpx;
		background-color: #ffffff;
		border-radius: 10rpx;
		padding: 0rpx 40rpx;
		justify-content: space-between;
		position: relative;
		margin-bottom: 2rpx;

	}

	.swiper {
		width: 100%;
	}

	.page-section-spacing {
		background-color: #f3f3f3;
		display: flex;
		justify-content: space-around;
	}

	.line {
		height: 6rpx;
		background-color: #FF5551;
		width: 120rpx;
		margin: auto;
		border-radius: 50rpx;
		margin-top: -4rpx;
	}

	.line-gray {
		height: 1rpx;
		width: 660rpx;
		background-color: #f0f0f0;
		margin: auto;
		border-radius: 24rpx;
		z-index: 99;
	}

	.scroll-view_H {
		white-space: nowrap;
		width: 90%;
	}

	.scroll-view-item_H>view {
		width: 200rpx;
		/* border:1px solid red; */
		font-size: 36rpx;
		line-height: 100rpx;
		margin-left: -20rpx;

	}

	.scroll-view-item_H {
		display: inline-block;
		width: 150rpx;
		height: 75rpx;
		line-height: 75rpx;
		text-align: center;
		font-size: 34rpx;
		/* margin-left: 28rpx; */
	}

	,
	.tab-bar {
		/* #ifdef APP-PLUS */
		width: 750rpx;
		/* #endif */
		height: 42px;
		flex-direction: row;
		/* #ifndef APP-PLUS */
		white-space: nowrap;
		/* #endif */
	}

	,
	.tabs {
		flex: 1;
		flex-direction: column;
		background-color: #f8f8f8;
	}

	.active {
		color: #a7a7a7;
	}

	.title {
		padding: 10rpx;
		font-size: 28rpx;
		width: 150rpx;
		text-align: center;

	}

	.box {
		/* flex-direction: row; */
		/* display: flex; */
		margin-top: 10rpx;
	}

	.box-c {
		flex-direction: column;
		display: flex;
	}
</style>
